#!/usr/bin/make -f
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 to 1999 by Joey Hess.
#
# adapted by Logilab for automatic generation by debianize
# (part of the devtools project, http://www.logilab.org/projects/devtools)
#
# Copyright (c) 2003-2010 LOGILAB S.A. (Paris, FRANCE).
# http://www.logilab.fr/ -- mailto:contact@logilab.fr

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

include /usr/share/python/python.mk

PYLIB:=$(call py_libdir,$(shell pyversions -d))
PACKAGE:=$(call py_pkgname,pylint,python)
PYLIB3:=$(call py_libdir,python3.)
PACKAGE3:="pylint3"

%:
	dh $@ --with python2,python3

override_dh_install:
	NO_SETUPTOOLS=1 python setup.py -q install --no-compile \
	                --root=$(CURDIR)/debian/$(PACKAGE)/ \
	                ${py_setup_install_args}
	NO_SETUPTOOLS=1 python3 setup.py -q install --no-compile \
	                --root=$(CURDIR)/debian/$(PACKAGE3)/ \
	                ${py_setup_install_args}
	# rename executables
	for executable in pylint symilar epylint pyreverse ; do \
		new_exec="$$executable"3; \
		sed 's,^#!.*python$$,&3,' < $(CURDIR)/debian/$(PACKAGE3)/usr/bin/$$executable > $(CURDIR)/debian/$(PACKAGE3)/usr/bin/$$new_exec || exit 1; \
	done
	# remove test directory
	rm -rf debian/*/usr/lib/python*/*-packages/pylint/test
	# generate pylint man page automatically
	#PYTHONPATH=$(CURDIR)/debian/$(PACKAGE)/$(PYLIB) python $(CURDIR)/bin/pylint --generate-man > $(CURDIR)/man/pylint.1
	# rename and install man pages
	dh_installman -ppylint man/*.1
	cd man && for i in *.1; do cp -v $$i "$$(basename $$i .1)3.1"; done
	dh_installman -ppylint3 man/*3.1

override_dh_installdocs:
	dh_installdocs README*
	dh_installchangelogs -i ChangeLog

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	# PYTHON 2.X
	# PYTHON 3.2
endif
